﻿<%@ Page Title="" Language="C#" MasterPageFile="~/master_form.master" AutoEventWireup="true" CodeFile="ds_hocsinh.aspx.cs" Inherits="App_Form_hs_ds_hocsinh" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <script type="text/javascript">
        Ext.require([
       'Ext.selection.CellModel',
       'Ext.grid.*',
       'Ext.data.*',
       'Ext.util.*',
       'Ext.state.*',
       'Ext.form.*',
       'Ext.grid.Panel'
        ]);
        Ext.onReady(function () {

            Ext.QuickTips.init();
            var bd = Ext.getBody();

            var simple = Ext.create('Ext.form.Panel', {
                title: 'Thông tin chung',
                id: 'from1',
                frame: true,
                autoHeight: true,
                width: '99%',
                bodyPadding: 10,
                defaults: {
                    anchor: '100%',
                    labelWidth: 100
                },
                items: [
                    {
                        xtype: 'fieldset',
                        title: 'Thông tin tìm kiếm',
                        layout: 'anchor',
                        defaults: {
                            labelWidth: 70,
                            anchor: '100%',
                            layout: {
                                type: 'hbox',
                                defaultMargins: { top: 0, right: 5, bottom: 0, left: 0 }
                            }
                        },
                        items: [
                            {
                                xtype: 'fieldcontainer',
                                combineErrors: true,
                                msgTarget: 'under',
                                width: 80,
                                items: [
                                     { xtype: 'displayfield', width: 70, fieldLabel: 'Hệ đào tạo' },
                                     {
                                         width: 150, xtype: 'combo',
                                         emptyText: 'Chọn hệ đào tạo', triggerAction: 'all', forceSelection: true,
                                         editable: false, id: 'he_dt', name: 'he_dt', displayField: 'Ten',
                                         valueField: 'ID', queryMode: 'local', store: null,
                                         listeners: {
                                             select: function (combo, record, index) {
                                                 if (record.length > 0) {
                                                     var id_ht_dt = record[0].get('ID');
                                                     //Goi service
                                                     wtkb.Fjson_Khoa_Lke(id_ht_dt, khoa_P_KQ, P_LOI_CSDL, P_LOI_TGIAN);
                                                 }
                                             }
                                         }
                                     },
                                    { xtype: 'displayfield', width: 70, fieldLabel: 'Khóa ĐT' },
                                    {
                                        width: 150, xtype: 'combo', triggerAction: 'all',
                                        emptyText: 'Chọn khóa', forceSelection: true,
                                        editable: false, id: 'khoa_dt',
                                        name: 'khoa_dt', displayField: 'Ten', valueField: 'ID',
                                        store: null,
                                        listeners: {
                                            select: function (combo, record, index) {
                                                if (record.length > 0) {
                                                    var id_nganh = record[0].get('ID');
                                                    //Goi service
                                                    wtkb.Fs_LOP_KHOA(id_nganh, lophoc_nganh_P_KQ, P_LOI_CSDL, P_LOI_TGIAN);
                                                }
                                            }
                                        }
                                    },
                                    { xtype: 'displayfield', width: 70, fieldLabel: 'Lớp' },
                                    {
                                        width: 150, xtype: 'combo', emptyText: 'Chọn lớp', triggerAction: 'all',
                                        forceSelection: true, editable: false,
                                        id: 'lop', name: 'lop', displayField: 'ten_lop', valueField: 'id_lop', queryMode: 'local', store: null
                                    },
                                    { xtype: 'displayfield', value: 'Mã SV', width: 80, hidden: true },
                                    { xtype: 'textfield',  id: 'ma', name: 'ma', width: 60, allowBlank: true, hidden: true },
                                    { xtype: 'displayfield', fieldLabel: 'Tên', width: 80 },
                                    { xtype: 'textfield', id: 'ten', name: 'ten', width: 100, allowBlank: true },
                                   {
                                       name: 'search',
                                       xtype: 'button',
                                       width: 70, icon: '../../shared/icons/fam/Find.ico',
                                       text: 'Tìm kiếm',
                                       handler: function () {
                                           var form = this.up('form').getForm()
                                           if (form.isValid()) {

                                               var a_kq = new Array();
                                               a_kq = form.getValues();
                                               if (!Fb_PT_JSON(a_kq, "lop")) { alert("Chưa chọn lớp"); return; }
                                               var b_ma = Ext.getCmp("ma").getValue(), b_ten = Ext.getCmp("ten").getValue(),
                                                   b_lop = Ext.getCmp("lop").getValue();
                                               //Goi service 

                                               wht.Fs_SINH_VIEN_TIM(b_ma, b_ten, b_lop, TIM_SINHVIEN_P_KQ, P_LOI_CSDL, P_LOI_TGIAN);
                                           }
                                       }
                                   }
                                ]
                            }
                        ]
                    },
                    {
                        xtype: 'gridpanel',
                        id: 'ds_sv',
                        anchor: '100%',
                        hight: 210,
                        store: null,
                        columns: [
                            { text: "Mã sinh viên", width: 100, flex: 1, sortable: true, dataIndex: 'MA_SV' },
                            { text: "Tên", width: 150, flex: 1, sortable: true, dataIndex: 'ten' },
                            { text: "Giới tính", width: 50, flex: 1, sortable: true, dataIndex: 'GioiTinh' },
                            { text: "Ngày sinh", width: 90, flex: 1, sortable: true, dataIndex: 'ngaysinh' },
                            { text: "Hộ khẩu thường trú", width: 200, flex: 1, sortable: true, dataIndex: 'HoKhauTT' },
                            { text: "Nơi sinh", width: 200, flex: 1, sortable: true, dataIndex: 'NoiSinh' }
                        ],
                        columnLines: true,
                        dockedItems: [{
                            xtype: 'toolbar',
                            items: [{
                                text: 'Thêm mới',
                                tooltip: 'Thêm bản ghi',
                                icon: '../../shared/icons/fam/add.gif',
                                handler: function () {
                                    Lib.Until.OpenWindow("Thêm sinh viên", "hso_sv.aspx?ma_sv=\"\"", 1024, 600);
                                }
                            }, '-', {
                                text: 'Thêm mới danh sách sinh viên',
                                tooltip: 'Thêm bản nghi',
                                icon: '../../shared/icons/fam/add.gif',
                                handler: function () {
                                    Lib.Until.OpenWindow("Hồ sơ sinh viên", "ds_sinhvien_nhap_excel.aspx", 400, 200);
                                }
                            }, '-', {
                                text: 'Sửa',
                                tooltip: 'Edit',
                                icon: '../../shared/icons/fam/edit.ico',
                                handler: function () {
                                    var b_rec = Ext.getCmp("ds_sv").getSelectionModel().getSelection()[0];
                                    if (!Ext.getCmp("ds_sv").getSelectionModel().getSelection()[0]) return alert("Chưa chọn sinh viên để sửa");
                                    var b_ma_sv = b_rec.get("MA_SV");
                                    Lib.Until.OpenWindow("Sửa thông tin sinh viên", "hso_sv.aspx?ma_sv=" + b_ma_sv + "", 1024, 600);
                                }
                            }, '-', {
                                text: 'Xóa',
                                tooltip: 'Xóa',
                                icon: '../../shared/icons/fam/delete.gif',
                                handler: function () {
                                    if (!Ext.getCmp("ds_sv").getSelectionModel().getSelection()[0])
                                        return alert("Chưa chọn sinh viên xóa");
                                    var b_rec = Ext.getCmp("ds_sv").getSelectionModel().getSelection()[0];
                                    var b_ma_sv = b_rec.get("MA_SV");
                                    if (b_ma_sv == "") return alert("Chưa chọn để xóa");
                                    var cfm = confirm("Bạn có chắc chắn xóa ?");
                                    if (cfm) {
                                        var b_loai_dt = Ext.getCmp("loai_dt").getValue(),
                                                           b_lop = Ext.getCmp("lop").getValue();
                                        wdkhp.Fs_SINHVIEN_XOA(b_ma_sv, b_loai_dt, b_lop, sinhvienxoa_P_KQ, P_LOI_CSDL, P_LOI_TGIAN);
                                    }
                                }
                                //
                            }]
                        }],
                        iconCls: 'icon-grid'
                    }
                ],
                renderTo: bd
            });
            wtkb.Fs_xep_mon_ttchung(P_LOAD_DATA, P_LOI_CSDL, P_LOI_TGIAN);
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
     <script type="text/javascript">
         function P_LOAD_DATA(b_kq) {
             if (Fb_LOI_KTRA(b_kq)) {
                 form_P_LOI(b_kq);
                 return;
             }
             else {
                 if (Fb_LOI_KTRA(b_kq)) {
                     form_P_LOI(b_kq);
                     return;
                 }
                 else {
                     var a_kq = b_kq.split('$');
                    
                     //Hệ đào tạo
                     var b_chuoi4 = CH_JSON(a_kq[4]);
                     var a_data4 = Ext.create('Ext.data.Store', {
                         fields: ['Ten', 'ID'],
                         data: b_chuoi4
                     });
                     var b_hk = Ext.getCmp("he_dt");
                     b_hk.bindStore(a_data4);
                 }
             }
         }
         function khoa_P_KQ(b_kq) {
             if (Fb_LOI_KTRA(b_kq)) {
                 form_P_LOI(b_kq);
                 return;
             }
             else {

                 var b_chuoi1 = CH_JSON(b_kq);
                 var a_data1 = Ext.create('Ext.data.Store', {
                     fields: ['ID', 'Ten', 'GhiChu'],
                     data: b_chuoi1
                 });
                 var c = Ext.getCmp('khoa_dt');
                 c.bindStore(a_data1);
             }
         }
         function lophoc_nganh_P_KQ(b_kq) {
             if (Fb_LOI_KTRA(b_kq)) {
                 form_P_LOI(b_kq);
                 return;
             }
             var b_chuoi = CH_JSON(b_kq);
             var a_data = Ext.create('Ext.data.Store', {
                 fields: ['id_lop', 'ten_lop'],
                 data: b_chuoi
             });
             Ext.getCmp('lop').bindStore(a_data);
         }
         function TIM_SINHVIEN_P_KQ(b_kq) {
             if (Fb_LOI_KTRA(b_kq)) {
                 form_P_LOI(b_kq);
                 return;
             }
             else {
                 var b_chuoi1 = CH_JSON(b_kq);
                 var store = Ext.create('Ext.data.JsonStore', {
                     fields: ['MA_SV', 'ten', 'GioiTinh', 'ngaysinh', 'HoKhauTT', 'NoiSinh'],
                     data: b_chuoi1
                 });
                 var b = Ext.getCmp('ds_sv');
                 b.bindStore(store);
             }
         }
    </script>
</asp:Content>

